﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace UnitTests
{
    public interface IParametersChain
    {
        void ProcessParameters(IList<string> paramsToProcess);
    }

    /// <summary>
    /// Using this attribute you can specify names of the fields to skip when checking a signature
    /// </summary>
    public class ExcludeParameters : Attribute, IParametersChain
    {
        private readonly string[] _ignoredParameters;

        public ExcludeParameters(params string[] ignoredParameters)
        {
            _ignoredParameters = ignoredParameters;
        }

        public void ProcessParameters(IList<string> paramsToProcess)
        {
            
            foreach (var parameter in _ignoredParameters)
            {
                var foundParameter =
                    paramsToProcess.FirstOrDefault(x => parameter.Equals(x, StringComparison.InvariantCultureIgnoreCase));
                if (foundParameter != null) //if contains
                {
                    paramsToProcess.Remove(foundParameter);
                }
            }
        }
    }

    /// <summary>
    /// Means that a method has an extended version so 'extended' param will be ignored 
    /// </summary>
    public class HasExtendedVersionAttribute : ExcludeParameters
    {
        public HasExtendedVersionAttribute() : base("extended")
        {
            
        }
    }
}